package com.tencent.xinge;


import org.json.JSONObject;


public class ClickAction {
    public static final int TYPE_ACTIVITY = 1;
    public static final int TYPE_URL = 2;
    public static final int TYPE_INTENT = 3;
    private int m_actionType;
    private String m_url;
    private int m_confirmOnUrl;


    public void setActionType(int actionType) {
        this.m_actionType = actionType;
    }

    public int getM_actionType() {
        return m_actionType;
    }

    public void setM_actionType(int m_actionType) {
        this.m_actionType = m_actionType;
    }

    public String getM_url() {
        return m_url;
    }

    public void setM_url(String m_url) {
        this.m_url = m_url;
    }

    public int getM_confirmOnUrl() {
        return m_confirmOnUrl;
    }

    public void setM_confirmOnUrl(int m_confirmOnUrl) {
        this.m_confirmOnUrl = m_confirmOnUrl;
    }

    public String getM_activity() {
        return m_activity;
    }

    public void setM_activity(String m_activity) {
        this.m_activity = m_activity;
    }

    public String getM_intent() {
        return m_intent;
    }

    public void setM_intent(String m_intent) {
        this.m_intent = m_intent;
    }

    public int getM_atyAttrIntentFlag() {
        return m_atyAttrIntentFlag;
    }

    public void setM_atyAttrIntentFlag(int m_atyAttrIntentFlag) {
        this.m_atyAttrIntentFlag = m_atyAttrIntentFlag;
    }

    public int getM_atyAttrPendingIntentFlag() {
        return m_atyAttrPendingIntentFlag;
    }

    public void setM_atyAttrPendingIntentFlag(int m_atyAttrPendingIntentFlag) {
        this.m_atyAttrPendingIntentFlag = m_atyAttrPendingIntentFlag;
    }

    public String getM_packageDownloadUrl() {
        return m_packageDownloadUrl;
    }

    public void setM_packageDownloadUrl(String m_packageDownloadUrl) {
        this.m_packageDownloadUrl = m_packageDownloadUrl;
    }

    public int getM_confirmOnPackageDownloadUrl() {
        return m_confirmOnPackageDownloadUrl;
    }

    public void setM_confirmOnPackageDownloadUrl(int m_confirmOnPackageDownloadUrl) {
        this.m_confirmOnPackageDownloadUrl = m_confirmOnPackageDownloadUrl;
    }

    public String getM_packageName() {
        return m_packageName;
    }

    public void setM_packageName(String m_packageName) {
        this.m_packageName = m_packageName;
    }


    private String m_activity;


    public void setActivity(String activity) {
        this.m_activity = activity;
    }


    private String m_intent;


    public void setUrl(String url) {
        this.m_url = url;
    }


    private int m_atyAttrIntentFlag;


    public void setConfirmOnUrl(int confirmOnUrl) {
        this.m_confirmOnUrl = confirmOnUrl;
    }


    private int m_atyAttrPendingIntentFlag;


    public void setIntent(String intent) {
        this.m_intent = intent;
    }


    private String m_packageDownloadUrl;


    public void setAtyAttrIntentFlag(int atyAttrIntentFlag) {
        this.m_atyAttrIntentFlag = atyAttrIntentFlag;
    }


    private int m_confirmOnPackageDownloadUrl;
    private String m_packageName;

    public void setAtyAttrPendingIntentFlag(int atyAttrPendingIntentFlag) {
        this.m_atyAttrPendingIntentFlag = atyAttrPendingIntentFlag;
    }


    public void setPackageDownloadUrl(String packageDownloadUrl) {
        this.m_packageDownloadUrl = packageDownloadUrl;
    }


    public void setConfirmOnPackageDownloadUrl(int confirmOnPackageDownloadUrl) {
        this.m_confirmOnPackageDownloadUrl = confirmOnPackageDownloadUrl;
    }


    public void setPackageName(String packageName) {
        this.m_packageName = packageName;
    }


    public String toJson() {
        JSONObject json = new JSONObject();
        json.put("action_type", this.m_actionType);
        JSONObject browser = new JSONObject();
        browser.put("url", this.m_url);
        browser.put("confirm", this.m_confirmOnUrl);
        json.put("browser", browser);
        json.put("activity", this.m_activity);
        json.put("intent", this.m_intent);

        JSONObject aty_attr = new JSONObject();
        aty_attr.put("if", this.m_atyAttrIntentFlag);
        aty_attr.put("pf", this.m_atyAttrPendingIntentFlag);
        json.put("aty_attr", aty_attr);

        return json.toString();
    }


    public JSONObject toJsonObject() {
        JSONObject json = new JSONObject();
        json.put("action_type", this.m_actionType);
        JSONObject browser = new JSONObject();
        browser.put("url", this.m_url);
        browser.put("confirm", this.m_confirmOnUrl);
        json.put("browser", browser);
        json.put("activity", this.m_activity);
        json.put("intent", this.m_intent);

        JSONObject aty_attr = new JSONObject();
        aty_attr.put("if", this.m_atyAttrIntentFlag);
        aty_attr.put("pf", this.m_atyAttrPendingIntentFlag);
        json.put("aty_attr", aty_attr);

        return json;
    }


    public boolean isValid() {
        if ((this.m_actionType < 1) || (this.m_actionType > 3)) {
            return false;
        }
        if (this.m_actionType == 2) {
            if ((this.m_url.isEmpty()) || (this.m_confirmOnUrl < 0) || (this.m_confirmOnUrl > 1))
                return false;
            return true;
        }
        if (this.m_actionType == 3) {
            if (this.m_intent.isEmpty())
                return false;
            return true;
        }
        return true;
    }


    public ClickAction() {
        this.m_url = "";
        this.m_actionType = 1;
        this.m_activity = "";

        this.m_atyAttrIntentFlag = 0;
        this.m_atyAttrPendingIntentFlag = 0;

        this.m_packageDownloadUrl = "";
        this.m_confirmOnPackageDownloadUrl = 1;
        this.m_packageName = "";
    }
}